#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
using ll = long long;
void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    size_t p1 = s.find("1"), p2 = s.find("1", p1 + 1), p3 = s.find("1", p2 + 1);
    //cout << p1 << ":" << p2 << ":" << p3 << endl;
    if((p2-p1) == (p3-p2))
    yes;
    else
        no;
}
int main()
{
    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
